{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## sklearn中的多项式回归和pipeline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np \n",
    "import matplotlib.pyplot as plt\n",
    "x = np.random.uniform(-3, 3, size=100)\n",
    "X = x.reshape(-1, 1)\n",
    "y = 0.5 * x**2 + x + 2 + np.random.normal(0, 1, 100)   #上一节中的函数关系"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.preprocessing import PolynomialFeatures       #数据预处理包"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "poly = PolynomialFeatures(degree=2)           # 2 ：对原有数据集最多添加几次幂的特征 X**2\n",
    "poly.fit(X)\n",
    "X2 = poly.transform(X)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(100, 3)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X2.shape        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 1.        , -0.42507542,  0.18068911],\n",
       "       [ 1.        ,  1.44092968,  2.07627834],\n",
       "       [ 1.        ,  2.41165732,  5.81609104],\n",
       "       [ 1.        , -0.46751134,  0.21856686],\n",
       "       [ 1.        , -1.59374056,  2.54000898]])"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X2[:5,:]  #看一下前5行   第一列看成X的0次方，第二列是X原来的样本特征X的1次方，第三列X的2次方"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-0.42507542],\n",
       "       [ 1.44092968],\n",
       "       [ 2.41165732],\n",
       "       [-0.46751134],\n",
       "       [-1.59374056]])"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X[:5,:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.linear_model import LinearRegression\n",
    "lin_reg2 = LinearRegression()\n",
    "lin_reg2.fit(X2, y)\n",
    "y_predict2 = lin_reg2.predict(X2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0xee091b4108>]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWoAAAD4CAYAAADFAawfAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nO3deXxU1f3/8dchhBI2AxoXIghWBQUUNK6ggqigIEQpij+1VIva1qp1QUH71bogm3Vpq7UoalXEDQxSVFzADRUBAUERRRAhCEYhIpBASM7vj5tAEmYmd2bunbkzeT8fjzyUySznTpLPnPs5n/s5xlqLiIgEV4NkD0BERCJToBYRCTgFahGRgFOgFhEJOAVqEZGAa+jHk+6zzz62Xbt2fjy1iEhaWrBgwY/W2pxQ3/MlULdr14758+f78dQiImnJGLM63PeU+hARCTgFahGRgFOgFhEJOAVqEZGAU6AWEQk4X6o+RETSWcHCQsbPXM664hJaZ2cxvE8H8rvl+vZ6CtQiIlEoWFjIyKlLKCkrB6CwuISRU5cA+BaslfoQEYnC+JnLdwXpKiVl5Yyfudy311SgFhGJwrrikqhu94ICtYhIFFpnZ0V1uxcUqEVEojC8TweyMjNq3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0yxMsYMNsZ8boypMMakZPmUMaavMWa5MWaFMWZEsscTD2PM48aYH4wxS5M9lngZY9oYY2YbY5ZV/o5dm+wxxcMY09gY84kxZnHl8dzh6fMnO0dtjGlhrd1c+f/XAEdYa/+Q1EHFwRhzJjDLWrvTGDMWwFp7c5KHFRNjzOFABfAf4EZr7fwkDykqxpgM4CvgDGAtMA+40Fr7RVIHFiNjzCnAFuApa23nZI8nHsaYA4ADrLWfGmOaAwuA/BT+2RigqbV2izEmE/gAuNZa+7EXz5/0GXVVkK7UFEjp1U1r7RvW2p2V//wYODCZ44mHtXaZtTaVd949DlhhrV1prd0BPAcMTPKYYmatfQ/YmOxxeMFa+7219tPK//8FWAakbKN269hS+c/Myi/PYlnSAzWAMWaUMWYNcBFwW7LH46HLgNeSPYh6LBdYU+3fa0nhYJCujDHtgG7A3OSOJD7GmAxjzCLgB+BNa61nx5OQQG2MecsYszTE10AAa+2t1to2wCTgz4kYUzzqOp7K+9wK7MQ5psBycywpzIS4LaXP2NKNMaYZMAX4S62z65RjrS231nbFOYs+zhjjWXoqIVtxWWtPd3nXZ4EZwO0+DidudR2PMWYo0B/obZO9CFCHKH42qWgt0Kbavw8E1iVpLFJLZS53CjDJWjs12ePxirW22BjzDtAX8GThN+mpD2PModX+OQD4Mllj8YIxpi9wMzDAWrst2eOp5+YBhxpj2htjGgFDgFeSPCZh1+LbRGCZtfa+ZI8nXsaYnKoKL2NMFnA6HsayIFR9TAE64FQXrAb+YK0tTOqg4mCMWQH8Cvip8qaPU7WKxRhzLvBPIAcoBhZZa/skd1TRMcacDTwAZACPW2tHJXlIMTPGTAZ64rTS3ADcbq2dmNRBxcgY0wN4H1iC87cPcIu19tXkjSp2xpgjgf/i/J41AF6w1t7p2fMnO1CLiEhkSU99iIhIZArUIiIBp0AtIhJwCtQiIgGnQC0iEnAK1CIiAadALSIScP8f0uTpjK0AuJ0AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(x, y)\n",
    "plt.plot(np.sort(x), y_predict2[np.argsort(x)], color='r')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0.        , 1.02963569, 0.45280878])"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lin_reg2.coef_        # 0：对X中第一列拟合的结果为0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2.053026663847385"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lin_reg2.intercept_   #截距"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 关于PolynomialFeatures"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "X = np.arange(1, 11)           #1-10\n",
    "X = X.reshape(-1, 2)          #5行2列，两个特征值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 1,  2],\n",
       "       [ 3,  4],\n",
       "       [ 5,  6],\n",
       "       [ 7,  8],\n",
       "       [ 9, 10]])"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "poly = PolynomialFeatures(degree=2)    \n",
    "poly.fit(X)\n",
    "X2 = poly.transform(X)                #拟合两个特征值的数据集；针对现有的X进行变形"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(5, 6)"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X2.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[  1.,   1.,   2.,   1.,   2.,   4.],\n",
       "       [  1.,   3.,   4.,   9.,  12.,  16.],\n",
       "       [  1.,   5.,   6.,  25.,  30.,  36.],\n",
       "       [  1.,   7.,   8.,  49.,  56.,  64.],\n",
       "       [  1.,   9.,  10.,  81.,  90., 100.]])"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X2  #第一列 0 次幂，第二三列 1 次幂，第四六列是 2 次幂，第五列是原来一二列的乘积"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  Pipeline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "# pipeline 能将 多项式特征、数据归一化、线性回归等步骤放到一起按步骤执行，而无需每次都重复三次"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = np.random.uniform(-3, 3, size=100)\n",
    "X = x.reshape(-1, 1)\n",
    "y = 0.5 * x**2 + x + 2 + np.random.normal(0, 1, 100)\n",
    "\n",
    "from sklearn.pipeline import Pipeline\n",
    "from sklearn.preprocessing import StandardScaler\n",
    "poly_reg = Pipeline([                              #传入列表，元组形式\n",
    "    (\"poly\", PolynomialFeatures(degree=2)),        #每个类都传入\n",
    "    (\"std_scaler\", StandardScaler()),              \n",
    "    (\"lin_reg\", LinearRegression())\n",
    "])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "poly_reg.fit(X, y)                    #将X， 有依次通过三个类\n",
    "y_predict = poly_reg.predict(X)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0xee0f555208>]"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD4CAYAAAD1jb0+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nO3deXhV1dn38e9NCBAGQQTKoAgqTmgFjDigaMEBBxDBAdSnVR9F+6jFoSpaK7XVglKtttoqLaC2iDggYFFxACdeRYOAE1JRxjA6RAUCBLLeP3YCySFn3mfY5/w+15Ur5GTn7LVDzn3WXute9zLnHCIiEjz1Mt0AERFJjAK4iEhAKYCLiASUAriISEApgIuIBFT9dJ6sVatWrlOnTuk8pYhI4M2bN+9r51zr0MfTGsA7depESUlJOk8pIhJ4Zra8rsc1hCIiElAK4CIiAaUALiISUArgIiIBpQAuIhJQac1CERHJB1PnlzJm5mJWl5XTvkURN512EAO7d/D9PArgIiI+mjq/lFunfEx5xQ4ASsvKuXXKxwC+B3ENoYiI+GjMzMU7g3e18oodjJm52PdzKYCLiPhodVl5XI8nQwFcRMRH7VsUxfV4MhTARUR8dNNpB1FUWFDrsaLCAm467SDfz6VJTBERH1VPVCoLRUQkgAZ275CSgB1KQygiIgGlHriIiM+0kEdEJIC0kEdEJKC0kEdEJKC0kEdEJKCyaiGPmY03s/Vm9kmNx1qa2atm9kXV5z19b5mISAClcyFPLD3wx4B+IY+NAF53znUBXq/6WkQk50ydX0qv0bPoPGIGvUbPYur80ojHD+zegVGDDqdDiyIM6NCiiFGDDk9JFoo556IfZNYJ+I9z7rCqrxcDJznn1phZO+AN51zUt5fi4mKnXelFJChCM0rA602nKiCHY2bznHPFoY8nOgb+E+fcGoCqz20inHiYmZWYWcmGDRsSPJ2ISPqlM6MkESmfx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
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(x, y)\n",
    "plt.plot(np.sort(x), y_predict[np.argsort(x)], color='r')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
